<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // let set = new Set();
        // let set2 = new Set(['大事儿', '小事儿', '好事儿', '坏事儿', '小事儿']);
        // console.log(set, typeof set);
        //添加新的元素
        // set2.add('喜事儿')
        //删除元素
        // set2.delete('坏事儿')
        //检测元素
        // console.log(set2.has("事儿"));
        //清空集合
        // set2.clear();
        // console.log(set2);

        // for (let v of set2) {
        //     console.log(v);
        // }

        let arr = [1, 2, 3, 4, 5, 4, 3];
        //1.数组去重
        // let result = [...new Set(arr)];
        // console.log(result);
        //2.交集
        let arr2 = [4, 5, 6, 6, 4, 7];
        // let result = [...new Set(arr)].filter(item => new Set(arr2).has(item));
        // console.log(result);
        //3.并集
        // let union = [...new Set([...arr, ...arr2])];
        // console.log(union);
        //4.差集
        let diff = [...new Set(arr)].filter(item => !(new Set(arr2).has(item)));
        console.log(diff);
    </script>
</body>

</html>